//
//  CFProgressHUDFadeAnimation.m
//  CFProgressHUD
//
//  Created by 千域互联 on 2018/3/18.
//  Copyright © 2018年 千域互联. All rights reserved.
//

#import "CFProgressHUDFadeAnimation.h"
#import "CFProgressHUD.h"

@implementation CFProgressHUDFadeAnimation

- (instancetype)init
{
    if (self = [super init]) {
        self.duration = .4;
        self.animationOptions = UIViewAnimationOptionCurveEaseInOut;
    }
    return self;
}
- (void)setAnimationOptions:(UIViewAnimationOptions)animationOptions
{
    _animationOptions = (animationOptions | UIViewAnimationOptionBeginFromCurrentState);
}

- (void)show
{
    [super show];
    
    self.progressHUD.alpha = 0.0;
    self.progressHUD.hidden = NO;
    
    [UIView animateWithDuration:self.duration animations:^{
        self.progressHUD.alpha = 1.0;
    } completion:^(BOOL finished) {
        [self animationFinished];
    }];
}
- (void)hide
{
    [super hide];
    
    [UIView animateWithDuration:self.duration animations:^{
        self.progressHUD.alpha = 0.0;
    } completion:^(BOOL finished) {
        [self animationFinished];
    }];
}

@end
